package com.cdcas;

import java.util.*;

public class IteratorTest2 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("222");
        list.add("wwww");
        list.add("777");
        list.add("99999");
//        Iterator<String> iterator = list.iterator();
//        while (iterator.hasNext()) {
//            System.out.println(iterator.next());
//        }
//        ListIterator<String> liter = list.listIterator();
//        System.out.println("从前往后输出");
//        while (liter.hasNext()) {
//            System.out.println(liter.next());
//        }
//        System.out.println("从后往前输出");
//        while (liter.hasPrevious()) {
//            System.out.println(liter.previous());
//        }
        Vector<String> vector = new Vector<>();
        vector.add("wwww");
        vector.add("7787");
        vector.add("666");
        Enumeration<String> enumeration = vector.elements();
        while (enumeration.hasMoreElements()){
            System.out.println(enumeration.nextElement());
        }
    }
}
